﻿using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using DBUtility;//Please add references
namespace DataAccess
{
	/// <summary>
	/// 数据访问类:MEDIUM_QT_T
	/// </summary>
	public partial class MEDIUM_QT_T
	{
		public MEDIUM_QT_T()
		{}
		#region  Method

		/// <summary>
		/// 是否存在该记录
		/// </summary>
        public static bool Exists(string MEDIUM_BH)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from MEDIUM_QT_T");
			strSql.Append(" where MEDIUM_BH=:MEDIUM_BH ");
			OracleParameter[] parameters = {
					new OracleParameter(":MEDIUM_BH", OracleType.NVarChar)};
			parameters[0].Value = MEDIUM_BH;

			return DbHelperOra.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
        public static bool Add(Model.MEDIUM_QT_T model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into MEDIUM_QT_T(");
			strSql.Append("MEDIUM_ID,MEDIUM_BH,MEDIUM_SN,MEDIUM_YT,MEDIUM_LY,MEDIUM_ZLMC,MEDIUM_ZLLX,MEDIUM_YHTGDW,MEDIUM_SYDW,MEDIUM_DJXH,MEDIUM_YHTGRQ,MEDIUM_USERQ,MEDIUM_LSH,MEDIUM_LX,MEDIUM_SYZT,MEDIUM_DYZT,CREATEUSER,CREATEDATE)");
			strSql.Append(" values (");
			strSql.Append(":MEDIUM_ID,:MEDIUM_BH,:MEDIUM_SN,:MEDIUM_YT,:MEDIUM_LY,:MEDIUM_ZLMC,:MEDIUM_ZLLX,:MEDIUM_YHTGDW,:MEDIUM_SYDW,:MEDIUM_DJXH,:MEDIUM_YHTGRQ,:MEDIUM_USERQ,:MEDIUM_LSH,:MEDIUM_LX,:MEDIUM_SYZT,:MEDIUM_DYZT,:CREATEUSER,:CREATEDATE)");
			OracleParameter[] parameters = {
					new OracleParameter(":MEDIUM_ID", OracleType.Number,10),
					new OracleParameter(":MEDIUM_BH", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_SN", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_YT", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_LY", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_ZLMC", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_ZLLX", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_YHTGDW", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_SYDW", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_DJXH", OracleType.Number,10),
					new OracleParameter(":MEDIUM_YHTGRQ", OracleType.DateTime),
					new OracleParameter(":MEDIUM_USERQ", OracleType.DateTime),
					new OracleParameter(":MEDIUM_LSH", OracleType.Number,10),
					new OracleParameter(":MEDIUM_LX", OracleType.Number,1),
					new OracleParameter(":MEDIUM_SYZT", OracleType.Number,1),
					new OracleParameter(":MEDIUM_DYZT", OracleType.Number,1),
					new OracleParameter(":CREATEUSER", OracleType.NVarChar),
					new OracleParameter(":CREATEDATE", OracleType.DateTime)};
			parameters[0].Value = model.MEDIUM_ID;
			parameters[1].Value = model.MEDIUM_BH;
			parameters[2].Value = model.MEDIUM_SN;
			parameters[3].Value = model.MEDIUM_YT;
			parameters[4].Value = model.MEDIUM_LY;
			parameters[5].Value = model.MEDIUM_ZLMC;
			parameters[6].Value = model.MEDIUM_ZLLX;
			parameters[7].Value = model.MEDIUM_YHTGDW;
			parameters[8].Value = model.MEDIUM_SYDW;
			parameters[9].Value = model.MEDIUM_DJXH;
			parameters[10].Value = model.MEDIUM_YHTGRQ;
			parameters[11].Value = model.MEDIUM_USERQ;
			parameters[12].Value = model.MEDIUM_LSH;
			parameters[13].Value = model.MEDIUM_LX;
			parameters[14].Value = model.MEDIUM_SYZT;
			parameters[15].Value = model.MEDIUM_DYZT;
			parameters[16].Value = model.CREATEUSER;
			parameters[17].Value = model.CREATEDATE;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
        public static bool Update(Model.MEDIUM_QT_T model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update MEDIUM_QT_T set ");
			strSql.Append("MEDIUM_ID=:MEDIUM_ID,");
			strSql.Append("MEDIUM_SN=:MEDIUM_SN,");
			strSql.Append("MEDIUM_YT=:MEDIUM_YT,");
			strSql.Append("MEDIUM_LY=:MEDIUM_LY,");
			strSql.Append("MEDIUM_ZLMC=:MEDIUM_ZLMC,");
			strSql.Append("MEDIUM_ZLLX=:MEDIUM_ZLLX,");
			strSql.Append("MEDIUM_YHTGDW=:MEDIUM_YHTGDW,");
			strSql.Append("MEDIUM_SYDW=:MEDIUM_SYDW,");
			strSql.Append("MEDIUM_DJXH=:MEDIUM_DJXH,");
			strSql.Append("MEDIUM_YHTGRQ=:MEDIUM_YHTGRQ,");
			strSql.Append("MEDIUM_USERQ=:MEDIUM_USERQ,");
			strSql.Append("MEDIUM_LSH=:MEDIUM_LSH,");
			strSql.Append("MEDIUM_LX=:MEDIUM_LX,");
			strSql.Append("MEDIUM_SYZT=:MEDIUM_SYZT,");
			strSql.Append("MEDIUM_DYZT=:MEDIUM_DYZT,");
			strSql.Append("CREATEUSER=:CREATEUSER,");
			strSql.Append("CREATEDATE=:CREATEDATE");
			strSql.Append(" where MEDIUM_BH=:MEDIUM_BH ");
			OracleParameter[] parameters = {
					new OracleParameter(":MEDIUM_ID", OracleType.Number,10),
					new OracleParameter(":MEDIUM_SN", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_YT", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_LY", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_ZLMC", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_ZLLX", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_YHTGDW", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_SYDW", OracleType.NVarChar),
					new OracleParameter(":MEDIUM_DJXH", OracleType.Number,10),
					new OracleParameter(":MEDIUM_YHTGRQ", OracleType.DateTime),
					new OracleParameter(":MEDIUM_USERQ", OracleType.DateTime),
					new OracleParameter(":MEDIUM_LSH", OracleType.Number,10),
					new OracleParameter(":MEDIUM_LX", OracleType.Number,1),
					new OracleParameter(":MEDIUM_SYZT", OracleType.Number,1),
					new OracleParameter(":MEDIUM_DYZT", OracleType.Number,1),
					new OracleParameter(":CREATEUSER", OracleType.NVarChar),
					new OracleParameter(":CREATEDATE", OracleType.DateTime),
					new OracleParameter(":MEDIUM_BH", OracleType.NVarChar)};
			parameters[0].Value = model.MEDIUM_ID;
			parameters[1].Value = model.MEDIUM_SN;
			parameters[2].Value = model.MEDIUM_YT;
			parameters[3].Value = model.MEDIUM_LY;
			parameters[4].Value = model.MEDIUM_ZLMC;
			parameters[5].Value = model.MEDIUM_ZLLX;
			parameters[6].Value = model.MEDIUM_YHTGDW;
			parameters[7].Value = model.MEDIUM_SYDW;
			parameters[8].Value = model.MEDIUM_DJXH;
			parameters[9].Value = model.MEDIUM_YHTGRQ;
			parameters[10].Value = model.MEDIUM_USERQ;
			parameters[11].Value = model.MEDIUM_LSH;
			parameters[12].Value = model.MEDIUM_LX;
			parameters[13].Value = model.MEDIUM_SYZT;
			parameters[14].Value = model.MEDIUM_DYZT;
			parameters[15].Value = model.CREATEUSER;
			parameters[16].Value = model.CREATEDATE;
			parameters[17].Value = model.MEDIUM_BH;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
        public static bool Delete(string MEDIUM_BH)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from MEDIUM_QT_T ");
			strSql.Append(" where MEDIUM_BH=:MEDIUM_BH ");
			OracleParameter[] parameters = {
					new OracleParameter(":MEDIUM_BH", OracleType.NVarChar)};
			parameters[0].Value = MEDIUM_BH;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
        public static bool DeleteList(string MEDIUM_BHlist)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from MEDIUM_QT_T ");
			strSql.Append(" where MEDIUM_BH in ("+MEDIUM_BHlist + ")  ");
			int rows=DbHelperOra.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
        public static Model.MEDIUM_QT_T GetModel(string MEDIUM_BH)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select MEDIUM_ID,MEDIUM_BH,MEDIUM_SN,MEDIUM_YT,MEDIUM_LY,MEDIUM_ZLMC,MEDIUM_ZLLX,MEDIUM_YHTGDW,MEDIUM_SYDW,MEDIUM_DJXH,MEDIUM_YHTGRQ,MEDIUM_USERQ,MEDIUM_LSH,MEDIUM_LX,MEDIUM_SYZT,MEDIUM_DYZT,CREATEUSER,CREATEDATE from MEDIUM_QT_T ");
			strSql.Append(" where MEDIUM_BH=:MEDIUM_BH ");
			OracleParameter[] parameters = {
					new OracleParameter(":MEDIUM_BH", OracleType.NVarChar)};
			parameters[0].Value = MEDIUM_BH;

			Model.MEDIUM_QT_T model=new Model.MEDIUM_QT_T();
			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["MEDIUM_ID"]!=null && ds.Tables[0].Rows[0]["MEDIUM_ID"].ToString()!="")
				{
					model.MEDIUM_ID=decimal.Parse(ds.Tables[0].Rows[0]["MEDIUM_ID"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_BH"]!=null && ds.Tables[0].Rows[0]["MEDIUM_BH"].ToString()!="")
				{
					model.MEDIUM_BH=ds.Tables[0].Rows[0]["MEDIUM_BH"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_SN"]!=null && ds.Tables[0].Rows[0]["MEDIUM_SN"].ToString()!="")
				{
					model.MEDIUM_SN=ds.Tables[0].Rows[0]["MEDIUM_SN"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_YT"]!=null && ds.Tables[0].Rows[0]["MEDIUM_YT"].ToString()!="")
				{
					model.MEDIUM_YT=ds.Tables[0].Rows[0]["MEDIUM_YT"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_LY"]!=null && ds.Tables[0].Rows[0]["MEDIUM_LY"].ToString()!="")
				{
					model.MEDIUM_LY=ds.Tables[0].Rows[0]["MEDIUM_LY"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_ZLMC"]!=null && ds.Tables[0].Rows[0]["MEDIUM_ZLMC"].ToString()!="")
				{
					model.MEDIUM_ZLMC=ds.Tables[0].Rows[0]["MEDIUM_ZLMC"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_ZLLX"]!=null && ds.Tables[0].Rows[0]["MEDIUM_ZLLX"].ToString()!="")
				{
					model.MEDIUM_ZLLX=ds.Tables[0].Rows[0]["MEDIUM_ZLLX"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_YHTGDW"]!=null && ds.Tables[0].Rows[0]["MEDIUM_YHTGDW"].ToString()!="")
				{
					model.MEDIUM_YHTGDW=ds.Tables[0].Rows[0]["MEDIUM_YHTGDW"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_SYDW"]!=null && ds.Tables[0].Rows[0]["MEDIUM_SYDW"].ToString()!="")
				{
					model.MEDIUM_SYDW=ds.Tables[0].Rows[0]["MEDIUM_SYDW"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_DJXH"]!=null && ds.Tables[0].Rows[0]["MEDIUM_DJXH"].ToString()!="")
				{
					model.MEDIUM_DJXH=decimal.Parse(ds.Tables[0].Rows[0]["MEDIUM_DJXH"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_YHTGRQ"]!=null && ds.Tables[0].Rows[0]["MEDIUM_YHTGRQ"].ToString()!="")
				{
					model.MEDIUM_YHTGRQ=DateTime.Parse(ds.Tables[0].Rows[0]["MEDIUM_YHTGRQ"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_USERQ"]!=null && ds.Tables[0].Rows[0]["MEDIUM_USERQ"].ToString()!="")
				{
					model.MEDIUM_USERQ=DateTime.Parse(ds.Tables[0].Rows[0]["MEDIUM_USERQ"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_LSH"]!=null && ds.Tables[0].Rows[0]["MEDIUM_LSH"].ToString()!="")
				{
					model.MEDIUM_LSH=decimal.Parse(ds.Tables[0].Rows[0]["MEDIUM_LSH"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_LX"]!=null && ds.Tables[0].Rows[0]["MEDIUM_LX"].ToString()!="")
				{
					model.MEDIUM_LX=decimal.Parse(ds.Tables[0].Rows[0]["MEDIUM_LX"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_SYZT"]!=null && ds.Tables[0].Rows[0]["MEDIUM_SYZT"].ToString()!="")
				{
					model.MEDIUM_SYZT=decimal.Parse(ds.Tables[0].Rows[0]["MEDIUM_SYZT"].ToString());
				}
				if(ds.Tables[0].Rows[0]["MEDIUM_DYZT"]!=null && ds.Tables[0].Rows[0]["MEDIUM_DYZT"].ToString()!="")
				{
					model.MEDIUM_DYZT=decimal.Parse(ds.Tables[0].Rows[0]["MEDIUM_DYZT"].ToString());
				}
				if(ds.Tables[0].Rows[0]["CREATEUSER"]!=null && ds.Tables[0].Rows[0]["CREATEUSER"].ToString()!="")
				{
					model.CREATEUSER=ds.Tables[0].Rows[0]["CREATEUSER"].ToString();
				}
				if(ds.Tables[0].Rows[0]["CREATEDATE"]!=null && ds.Tables[0].Rows[0]["CREATEDATE"].ToString()!="")
				{
					model.CREATEDATE=DateTime.Parse(ds.Tables[0].Rows[0]["CREATEDATE"].ToString());
				}
				return model;
			}
			else
			{
				return null;
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
        public static DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select MEDIUM_ID,MEDIUM_BH,MEDIUM_SN,MEDIUM_YT,MEDIUM_LY,MEDIUM_ZLMC,MEDIUM_ZLLX,MEDIUM_YHTGDW,MEDIUM_SYDW,MEDIUM_DJXH,MEDIUM_YHTGRQ,MEDIUM_USERQ,MEDIUM_LSH,MEDIUM_LX,MEDIUM_SYZT,MEDIUM_DYZT,CREATEUSER,CREATEDATE ");
			strSql.Append(" FROM MEDIUM_QT_T ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperOra.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			OracleParameter[] parameters = {
					new OracleParameter(":tblName", OracleType.VarChar, 255),
					new OracleParameter(":fldName", OracleType.VarChar, 255),
					new OracleParameter(":PageSize", OracleType.Number),
					new OracleParameter(":PageIndex", OracleType.Number),
					new OracleParameter(":IsReCount", OracleType.Clob),
					new OracleParameter(":OrderType", OracleType.Clob),
					new OracleParameter(":strWhere", OracleType.VarChar,1000),
					};
			parameters[0].Value = "MEDIUM_QT_T";
			parameters[1].Value = "MEDIUM_BH";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperOra.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  Method
	}
}

